package com.mjk.common.tools.logger;

import ch.qos.logback.classic.spi.ILoggingEvent;
import ch.qos.logback.core.filter.Filter;
import ch.qos.logback.core.spi.FilterReply;
import com.mjk.common.util.ObjectUtils;

/**
 * 日志过滤器
 */
public class LogFilter extends Filter<ILoggingEvent> {
	@Override
	public FilterReply decide(ILoggingEvent event) {
		if (ObjectUtils.isNotEmpty(event.getThreadName())&&
				(event.getThreadName().contains("DBSingelPointImpl") //单点检测
				||event.getThreadName().contains("SQL-Polling-")
						|| event.getThreadName().contains("Nacos-Polling")
				))//liteflow 定时检测
		{
			return FilterReply.DENY;
		} else if(event.getMessage().contains("dict_singel")
				||event.getMessage().contains("DefaultSqlSession")
				||event.getMessage().contains("Creating a new SqlSession")
				||event.getMessage().contains("will not be managed by Spring")) {
			return FilterReply.DENY;
		}else {
			return FilterReply.NEUTRAL;
		}
	}
}